package kr.haggenna.member.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import kr.haggenna.member.dao.MemberDao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class DeleteController {
	@Autowired
	private MemberDao memberDao;
	
	public void setMemberDao(MemberDao memberDao){
		this.memberDao = memberDao;
	}
	
	@RequestMapping("/delete.do")
	public String form(){
		return "deleteForm";
	}
	
	@RequestMapping("/deleteForm.do")
	public String process(@RequestParam("email") String email, HttpServletRequest request){

		memberDao.deleteMember(email);
		HttpSession session = request.getSession();
		session.invalidate();
		
		return "deletePro";
	}
	
}
